package com.sh.data.engine.domain.integration.api.http.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.sh.data.engine.domain.base.model.PageResult;
import com.sh.data.engine.domain.integration.api.http.model.domain.ApiTaskDomain;
import com.sh.data.engine.domain.integration.api.http.model.domain.TaskDomain;
import com.sh.data.engine.domain.integration.api.http.model.domain.TaskOverviewDomain;
import com.sh.data.engine.domain.integration.api.http.model.domain.TestApiHttpDomain;
import com.sh.data.engine.domain.integration.api.http.model.param.ApiHttpAuthParam;
import com.sh.data.engine.domain.integration.api.http.model.param.ApiHttpRequestBodyParam.FormParam;
import com.sh.data.engine.domain.integration.api.http.model.param.ApiHttpRequestHeaderParam;
import com.sh.data.engine.domain.integration.api.http.model.param.ApiHttpSaveParam;
import com.sh.data.engine.domain.integration.api.http.model.param.TestApiHttpParam;
import com.sh.data.engine.domain.integration.api.taskconfig.model.domain.TaskItemDomain;
import com.sh.data.engine.domain.integration.api.taskconfig.model.param.TaskConfigParam;
import com.sh.data.engine.domain.integration.api.taskconfig.service.TaskConfigService;
import com.sh.data.engine.repository.dao.integration.api.http.entity.ApiHttpEntity;
import okhttp3.Request;

import java.util.List;
import java.util.Map;

/**
 * @author : changkong
 * @date : 2022/3/11
 */
public interface ApiHttpService extends TaskConfigService, IService<ApiHttpEntity> {

    public TestApiHttpDomain testApiHttp(TestApiHttpParam testApiHttpParam);

    void delete(Long id);

    Long run(Long taskId);

    Long executeApiHttp(Long taskId, Integer executeType, Map<String, String> param);


    Integer generateJobId(ApiHttpEntity apiHttpEntity, TaskConfigParam task);

    TaskOverviewDomain getOverview(Long projectId);

    PageResult<TaskItemDomain> getTaskPage(
        Integer pageNum, Integer pageSize, Integer status, String search);

    void updateAfterStart(Long id);

    void updateAfterStop(Long logId, Integer status);

    Boolean save(ApiHttpSaveParam apiHttpSaveParam);

    String buildApiDataxJson(Long id, Map<String, String> param);

    Long getApiIdByXxlId(Long xxlId);

    TaskDomain getTaskById(Long taskId);

    Request buildRequest(
        String url,
        String httpRequestMethod,
        ApiHttpAuthParam apiHttpAuthParam,
        ApiHttpRequestHeaderParam apiHttpRequestHeaderParam,
        String contentType,
        List<FormParam> formParams,
        String rawJson);

    List<ApiTaskDomain> getApiTaskDomainList(Long projectId);

    List<TaskDomain> getListByPage(Long projectId, Integer pageSize, Integer pageNum);

    List<ApiHttpEntity> getApiHttpTaskEntityList(Long projectId);

    Integer getTaskStatus(Long jobId);

    List<String> getNodeTableById(Long jobId);
}
